<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="language" content="en" />
        <link href="./assets/ffd55088/css/bootstrap.css" rel="stylesheet">
<link href="./assets/5cf9384a/solarized_light.css" rel="stylesheet">
<link href="./assets/6c54116e/style.css" rel="stylesheet">
<script src="./assets/a44cef0f/jquery.js"></script>
<script src="./assets/ffd55088/js/bootstrap.js"></script>
<script src="./assets/8ac4e28a/jssearch.js"></script>    <title>Query, yii\elasticsearch\Query - Yii Framework 2.0 API Documentation</title>
</head>
<body>

<div class="wrap">
    <nav id="w11609" class="navbar-inverse navbar-fixed-top navbar" role="navigation"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w11609-collapse"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button><a class="navbar-brand" href="./index.html">Yii Framework 2.0 API Documentation</a></div><div id="w11609-collapse" class="collapse navbar-collapse"><ul id="w11610" class="navbar-nav nav"><li><a href="./index.html">Class reference</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Extensions <b class="caret"></b></a><ul id="w11611" class="dropdown-menu"><li><a href="./ext-apidoc-index.html" tabindex="-1">apidoc</a></li>
<li><a href="./ext-authclient-index.html" tabindex="-1">authclient</a></li>
<li><a href="./ext-bootstrap-index.html" tabindex="-1">bootstrap</a></li>
<li><a href="./ext-codeception-index.html" tabindex="-1">codeception</a></li>
<li><a href="./ext-debug-index.html" tabindex="-1">debug</a></li>
<li><a href="./ext-elasticsearch-index.html" tabindex="-1">elasticsearch</a></li>
<li><a href="./ext-faker-index.html" tabindex="-1">faker</a></li>
<li><a href="./ext-gii-index.html" tabindex="-1">gii</a></li>
<li><a href="./ext-imagine-index.html" tabindex="-1">imagine</a></li>
<li><a href="./ext-jui-index.html" tabindex="-1">jui</a></li>
<li><a href="./ext-mongodb-index.html" tabindex="-1">mongodb</a></li>
<li><a href="./ext-redis-index.html" tabindex="-1">redis</a></li>
<li><a href="./ext-smarty-index.html" tabindex="-1">smarty</a></li>
<li><a href="./ext-sphinx-index.html" tabindex="-1">sphinx</a></li>
<li><a href="./ext-swiftmailer-index.html" tabindex="-1">swiftmailer</a></li>
<li><a href="./ext-twig-index.html" tabindex="-1">twig</a></li></ul></li>
<li><a href="./guide-README.html">Guide</a></li></ul><div class="navbar-form navbar-left" role="search">
  <div class="form-group">
    <input id="searchbox" type="text" class="form-control" placeholder="Search">
  </div>
</div>
</div></nav>
    <div id="search-resultbox" style="display: none;" class="modal-content">
        <ul id="search-results">
        </ul>
    </div>

    
<div class="row">
    <div class="col-md-3">
                <div id="navigation" class="list-group"><a class="list-group-item active" href="#navigation-11608" data-toggle="collapse" data-parent="#navigation">yii\elasticsearch <b class="caret"></b></a><div id="navigation-11608" class="submenu panel-collapse collapse in"><a class="list-group-item" href="./yii-elasticsearch-activedataprovider.html">ActiveDataProvider</a>
<a class="list-group-item" href="./yii-elasticsearch-activefixture.html">ActiveFixture</a>
<a class="list-group-item" href="./yii-elasticsearch-activequery.html">ActiveQuery</a>
<a class="list-group-item" href="./yii-elasticsearch-activerecord.html">ActiveRecord</a>
<a class="list-group-item" href="./yii-elasticsearch-batchqueryresult.html">BatchQueryResult</a>
<a class="list-group-item" href="./yii-elasticsearch-bulkcommand.html">BulkCommand</a>
<a class="list-group-item" href="./yii-elasticsearch-command.html">Command</a>
<a class="list-group-item" href="./yii-elasticsearch-connection.html">Connection</a>
<a class="list-group-item" href="./yii-elasticsearch-debugaction.html">DebugAction</a>
<a class="list-group-item" href="./yii-elasticsearch-debugpanel.html">DebugPanel</a>
<a class="list-group-item" href="./yii-elasticsearch-exception.html">Exception</a>
<a class="list-group-item active" href="./yii-elasticsearch-query.html">Query</a>
<a class="list-group-item" href="./yii-elasticsearch-querybuilder.html">QueryBuilder</a></div></div>    </div>
    <div class="col-md-9 api-content" role="main">
        <h1>Class yii\elasticsearch\Query</h1>
<div class="top-nav">
    <a href="index.html">All Classes</a>
            | <a href="#properties">Properties</a>
                | <a href="#methods">Methods</a>
            </div>

<table class="summaryTable docClass table table-bordered">
    <colgroup>
        <col class="col-name" />
        <col class="col-value" />
    </colgroup>
            <tr><th>Inheritance</th><td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a> &raquo;
<a href="yii-base-component.html">yii\base\Component</a> &raquo;
<a href="yii-base-object.html">yii\base\Object</a></td></tr>
                <tr><th>Implements</th><td><a href="yii-base-configurable.html">yii\base\Configurable</a>, <a href="yii-db-queryinterface.html">yii\db\QueryInterface</a></td></tr>
                    <tr><th>Uses Traits</th><td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td></tr>
                <tr><th>Subclasses</th><td><a href="yii-elasticsearch-activequery.html">yii\elasticsearch\ActiveQuery</a></td></tr>
                        <tr><th>Available since version</th><td>2.0</td></tr>
                    <tr>
          <th>Source Code</th>
          <td><a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php">https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php</a></td>
        </tr>
    </table>

<div class="class-description">
    <p><strong>Query represents a query to the search API of elasticsearch.</strong></p>
    <p>Query provides a set of methods to facilitate the specification of different parameters of the query.
These methods can be chained together.</p>
<p>By calling <a href="yii-elasticsearch-query.html#createCommand()-detail">createCommand()</a>, we can get a <a href="yii-elasticsearch-command.html">yii\elasticsearch\Command</a> instance which can be further
used to perform/execute the DB query against a database.</p>
<p>For example,</p>
<pre><code class="hljs php"><span class="hljs-variable">$query</span> = <span class="hljs-keyword">new</span> Query;
<span class="hljs-variable">$query</span>-&gt;fields(<span class="hljs-string">'id, name'</span>)
    -&gt;from(<span class="hljs-string">'myindex'</span>, <span class="hljs-string">'users'</span>)
    -&gt;limit(<span class="hljs-number">10</span>);
<span class="hljs-comment">// build and execute the query</span>
<span class="hljs-variable">$command</span> = <span class="hljs-variable">$query</span>-&gt;createCommand();
<span class="hljs-variable">$rows</span> = <span class="hljs-variable">$command</span>-&gt;search(); <span class="hljs-comment">// this way you get the raw output of elasticsearch.</span>
</code></pre>
<p>You would normally call <code>$query-&gt;search()</code> instead of creating a command as this method
adds the <code>indexBy()</code> feature and also removes some inconsistencies from the response.</p>
<p>Query also provides some methods to easier get some parts of the result only:</p>
<ul>
<li><a href="yii-elasticsearch-query.html#one()-detail">one()</a>: returns a single record populated with the first row of data.</li>
<li><a href="yii-elasticsearch-query.html#all()-detail">all()</a>: returns all records based on the query results.</li>
<li><a href="yii-elasticsearch-query.html#count()-detail">count()</a>: returns the number of records.</li>
<li><a href="yii-elasticsearch-query.html#scalar()-detail">scalar()</a>: returns the value of the first column in the first row of the query result.</li>
<li><a href="yii-elasticsearch-query.html#column()-detail">column()</a>: returns the value of the first column in the query result.</li>
<li><a href="yii-elasticsearch-query.html#exists()-detail">exists()</a>: returns a value indicating whether the query result has data or not.</li>
</ul>
<p>NOTE: elasticsearch limits the number of records returned to 10 records by default.
If you expect to get more records you should specify limit explicitly.</p>

    </div>

<a id="properties"></a>

<div class="summary doc-property">
<h2>Public Properties</h2>

<p><a href="#" class="toggle">Hide inherited properties</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-property" />
    <col class="col-type" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Property</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr>
        <tr id="$aggregations">
        <td><a href="yii-elasticsearch-query.html#$aggregations-detail">$aggregations</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>List of aggregations to add to this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="$behaviors">
        <td><a href="yii-base-component.html#$behaviors-detail">$behaviors</a></td>
        <td><a href="yii-base-behavior.html">yii\base\Behavior</a>[]</td>
        <td>List of behaviors attached to this component</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="$fields">
        <td><a href="yii-elasticsearch-query.html#$fields-detail">$fields</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>The fields being retrieved from the documents.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$filter">
        <td><a href="yii-elasticsearch-query.html#$filter-detail">$filter</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.string">string</a></td>
        <td>The filter part of this search query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$highlight">
        <td><a href="yii-elasticsearch-query.html#$highlight-detail">$highlight</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>The highlight part of this search query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$index">
        <td><a href="yii-elasticsearch-query.html#$index-detail">$index</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
        <td>The index to retrieve data from.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="$indexBy">
        <td><a href="yii-db-querytrait.html#$indexBy-detail">$indexBy</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.callable">callable</a></td>
        <td>The name of the column by which the query results should be indexed by.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="$limit">
        <td><a href="yii-db-querytrait.html#$limit-detail">$limit</a></td>
        <td><a href="http://www.php.net/language.types.integer">integer</a></td>
        <td>Maximum number of records to be returned.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="$minScore">
        <td><a href="yii-elasticsearch-query.html#$minScore-detail">$minScore</a></td>
        <td><a href="http://www.php.net/language.types.float">float</a></td>
        <td>Exclude documents which have a _score less than the minimum specified in min_score</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="$offset">
        <td><a href="yii-db-querytrait.html#$offset-detail">$offset</a></td>
        <td><a href="http://www.php.net/language.types.integer">integer</a></td>
        <td>Zero-based offset from where the records are to be returned.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="$options">
        <td><a href="yii-elasticsearch-query.html#$options-detail">$options</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>List of options that will passed to commands created by this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="$orderBy">
        <td><a href="yii-db-querytrait.html#$orderBy-detail">$orderBy</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>How to sort the query results.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="$query">
        <td><a href="yii-elasticsearch-query.html#$query-detail">$query</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.string">string</a></td>
        <td>The query part of this search query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$source">
        <td><a href="yii-elasticsearch-query.html#$source-detail">$source</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>This option controls how the <code>_source</code> field is returned from the documents.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$stats">
        <td><a href="yii-elasticsearch-query.html#$stats-detail">$stats</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>The 'stats' part of the query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$suggest">
        <td><a href="yii-elasticsearch-query.html#$suggest-detail">$suggest</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>List of suggesters to add to this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$timeout">
        <td><a href="yii-elasticsearch-query.html#$timeout-detail">$timeout</a></td>
        <td><a href="http://www.php.net/language.types.integer">integer</a></td>
        <td>A search timeout, bounding the search request to be executed within the specified time value
and bail with the hits accumulated up to that point when expired.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="$type">
        <td><a href="yii-elasticsearch-query.html#$type-detail">$type</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
        <td>The type to retrieve data from.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="$where">
        <td><a href="yii-db-querytrait.html#$where-detail">$where</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
        <td>Query condition.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
    </table>
</div>

<a id="methods"></a>

<div class="summary doc-method">
<h2>Public Methods</h2>

<p><a href="#" class="toggle">Hide inherited methods</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-method" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Method</th><th>Description</th><th>Defined By</th>
</tr>
        <tr class="inherited" id="__call()">
        <td><a href="yii-base-component.html#__call()-detail">__call()</a></td>
        <td>Calls the named method which is not a class method.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__clone()">
        <td><a href="yii-base-component.html#__clone()-detail">__clone()</a></td>
        <td>This method is called after the object is created by cloning an existing one.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__construct()">
        <td><a href="yii-base-object.html#__construct()-detail">__construct()</a></td>
        <td>Constructor.</td>
        <td><a href="yii-base-object.html">yii\base\Object</a></td>
    </tr>
            <tr class="inherited" id="__get()">
        <td><a href="yii-base-component.html#__get()-detail">__get()</a></td>
        <td>Returns the value of a component property.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__isset()">
        <td><a href="yii-base-component.html#__isset()-detail">__isset()</a></td>
        <td>Checks if a property is set, i.e. defined and not null.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__set()">
        <td><a href="yii-base-component.html#__set()-detail">__set()</a></td>
        <td>Sets the value of a component property.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__unset()">
        <td><a href="yii-base-component.html#__unset()-detail">__unset()</a></td>
        <td>Sets a component property to be null.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="addAgg()">
        <td><a href="yii-elasticsearch-query.html#addAgg()-detail">addAgg()</a></td>
        <td>Adds an aggregation to this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="addAggregation()">
        <td><a href="yii-elasticsearch-query.html#addAggregation()-detail">addAggregation()</a></td>
        <td>Adds an aggregation to this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="addOptions()">
        <td><a href="yii-elasticsearch-query.html#addOptions()-detail">addOptions()</a></td>
        <td>Adds more options, overwriting existing options.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="addOrderBy()">
        <td><a href="yii-db-querytrait.html#addOrderBy()-detail">addOrderBy()</a></td>
        <td>Adds additional ORDER BY columns to the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="addSuggester()">
        <td><a href="yii-elasticsearch-query.html#addSuggester()-detail">addSuggester()</a></td>
        <td>Adds a suggester to this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="all()">
        <td><a href="yii-elasticsearch-query.html#all()-detail">all()</a></td>
        <td>Executes the query and returns all results as an array.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="andFilterWhere()">
        <td><a href="yii-db-querytrait.html#andFilterWhere()-detail">andFilterWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="andWhere()">
        <td><a href="yii-db-querytrait.html#andWhere()-detail">andWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="attachBehavior()">
        <td><a href="yii-base-component.html#attachBehavior()-detail">attachBehavior()</a></td>
        <td>Attaches a behavior to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="attachBehaviors()">
        <td><a href="yii-base-component.html#attachBehaviors()-detail">attachBehaviors()</a></td>
        <td>Attaches a list of behaviors to the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="batch()">
        <td><a href="yii-elasticsearch-query.html#batch()-detail">batch()</a></td>
        <td>Starts a batch query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="behaviors()">
        <td><a href="yii-base-component.html#behaviors()-detail">behaviors()</a></td>
        <td>Returns a list of behaviors that this component should behave as.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="canGetProperty()">
        <td><a href="yii-base-component.html#canGetProperty()-detail">canGetProperty()</a></td>
        <td>Returns a value indicating whether a property can be read.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="canSetProperty()">
        <td><a href="yii-base-component.html#canSetProperty()-detail">canSetProperty()</a></td>
        <td>Returns a value indicating whether a property can be set.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="className()">
        <td><a href="yii-base-object.html#className()-detail">className()</a></td>
        <td>Returns the fully qualified name of this class.</td>
        <td><a href="yii-base-object.html">yii\base\Object</a></td>
    </tr>
            <tr id="column()">
        <td><a href="yii-elasticsearch-query.html#column()-detail">column()</a></td>
        <td>Executes the query and returns the first column of the result.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="count()">
        <td><a href="yii-elasticsearch-query.html#count()-detail">count()</a></td>
        <td>Returns the number of records.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="createCommand()">
        <td><a href="yii-elasticsearch-query.html#createCommand()-detail">createCommand()</a></td>
        <td>Creates a DB command that can be used to execute this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="delete()">
        <td><a href="yii-elasticsearch-query.html#delete()-detail">delete()</a></td>
        <td>Executes the query and deletes all matching documents.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="detachBehavior()">
        <td><a href="yii-base-component.html#detachBehavior()-detail">detachBehavior()</a></td>
        <td>Detaches a behavior from the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="detachBehaviors()">
        <td><a href="yii-base-component.html#detachBehaviors()-detail">detachBehaviors()</a></td>
        <td>Detaches all behaviors from the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="each()">
        <td><a href="yii-elasticsearch-query.html#each()-detail">each()</a></td>
        <td>Starts a batch query and retrieves data row by row.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="ensureBehaviors()">
        <td><a href="yii-base-component.html#ensureBehaviors()-detail">ensureBehaviors()</a></td>
        <td>Makes sure that the behaviors declared in <a href="yii-base-component.html#behaviors()-detail">behaviors()</a> are attached to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="exists()">
        <td><a href="yii-elasticsearch-query.html#exists()-detail">exists()</a></td>
        <td>Returns a value indicating whether the query result contains any row of data.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="fields()">
        <td><a href="yii-elasticsearch-query.html#fields()-detail">fields()</a></td>
        <td>Sets the fields to retrieve from the documents.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="filter()">
        <td><a href="yii-elasticsearch-query.html#filter()-detail">filter()</a></td>
        <td>Sets the filter part of this search query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
                <tr class="inherited" id="filterWhere()">
        <td><a href="yii-db-querytrait.html#filterWhere()-detail">filterWhere()</a></td>
        <td>Sets the WHERE part of the query but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="from()">
        <td><a href="yii-elasticsearch-query.html#from()-detail">from()</a></td>
        <td>Sets the index and type to retrieve documents from.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="getBehavior()">
        <td><a href="yii-base-component.html#getBehavior()-detail">getBehavior()</a></td>
        <td>Returns the named behavior object.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="getBehaviors()">
        <td><a href="yii-base-component.html#getBehaviors()-detail">getBehaviors()</a></td>
        <td>Returns all behaviors attached to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="hasEventHandlers()">
        <td><a href="yii-base-component.html#hasEventHandlers()-detail">hasEventHandlers()</a></td>
        <td>Returns a value indicating whether there is any handler attached to the named event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="hasMethod()">
        <td><a href="yii-base-component.html#hasMethod()-detail">hasMethod()</a></td>
        <td>Returns a value indicating whether a method is defined.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="hasProperty()">
        <td><a href="yii-base-component.html#hasProperty()-detail">hasProperty()</a></td>
        <td>Returns a value indicating whether a property is defined for this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="highlight()">
        <td><a href="yii-elasticsearch-query.html#highlight()-detail">highlight()</a></td>
        <td>Sets a highlight parameters to retrieve from the documents.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="indexBy()">
        <td><a href="yii-db-querytrait.html#indexBy()-detail">indexBy()</a></td>
        <td>Sets the <a href="yii-db-querytrait.html#indexBy()-detail">indexBy()</a> property.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="init()">
        <td><a href="yii-elasticsearch-query.html#init()-detail">init()</a></td>
        <td>Initializes the object.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
                <tr class="inherited" id="limit()">
        <td><a href="yii-db-querytrait.html#limit()-detail">limit()</a></td>
        <td>Sets the LIMIT part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="minScore()">
        <td><a href="yii-elasticsearch-query.html#minScore()-detail">minScore()</a></td>
        <td></td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
                <tr class="inherited" id="off()">
        <td><a href="yii-base-component.html#off()-detail">off()</a></td>
        <td>Detaches an existing event handler from this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="offset()">
        <td><a href="yii-db-querytrait.html#offset()-detail">offset()</a></td>
        <td>Sets the OFFSET part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="on()">
        <td><a href="yii-base-component.html#on()-detail">on()</a></td>
        <td>Attaches an event handler to an event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="one()">
        <td><a href="yii-elasticsearch-query.html#one()-detail">one()</a></td>
        <td>Executes the query and returns a single row of result.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="options()">
        <td><a href="yii-elasticsearch-query.html#options()-detail">options()</a></td>
        <td>Sets the options to be passed to the command created by this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="orFilterWhere()">
        <td><a href="yii-db-querytrait.html#orFilterWhere()-detail">orFilterWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="orWhere()">
        <td><a href="yii-db-querytrait.html#orWhere()-detail">orWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="orderBy()">
        <td><a href="yii-db-querytrait.html#orderBy()-detail">orderBy()</a></td>
        <td>Sets the ORDER BY part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="populate()">
        <td><a href="yii-elasticsearch-query.html#populate()-detail">populate()</a></td>
        <td>Converts the raw query results into the format as specified by this query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="query()">
        <td><a href="yii-elasticsearch-query.html#query()-detail">query()</a></td>
        <td>Sets the querypart of this search query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="scalar()">
        <td><a href="yii-elasticsearch-query.html#scalar()-detail">scalar()</a></td>
        <td>Returns the query result as a scalar value.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="search()">
        <td><a href="yii-elasticsearch-query.html#search()-detail">search()</a></td>
        <td>Executes the query and returns the complete search result including e.g. hits, facets, totalCount.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="source()">
        <td><a href="yii-elasticsearch-query.html#source()-detail">source()</a></td>
        <td>Sets the source filtering, specifying how the <code>_source</code> field of the document should be returned.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="stats()">
        <td><a href="yii-elasticsearch-query.html#stats()-detail">stats()</a></td>
        <td>Adds a 'stats' part to the query.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr id="timeout()">
        <td><a href="yii-elasticsearch-query.html#timeout()-detail">timeout()</a></td>
        <td>Sets the search timeout.</td>
        <td><a href="yii-elasticsearch-query.html">yii\elasticsearch\Query</a></td>
    </tr>
            <tr class="inherited" id="trigger()">
        <td><a href="yii-base-component.html#trigger()-detail">trigger()</a></td>
        <td>Triggers an event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="where()">
        <td><a href="yii-db-querytrait.html#where()-detail">where()</a></td>
        <td>Sets the WHERE part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
    </table>
</div>

<div class="summary doc-method">
<h2>Protected Methods</h2>

<p><a href="#" class="toggle">Hide inherited methods</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-method" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Method</th><th>Description</th><th>Defined By</th>
</tr>
                                                                                                                                            <tr class="inherited" id="filterCondition()">
        <td><a href="yii-db-querytrait.html#filterCondition()-detail">filterCondition()</a></td>
        <td>Removes <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a> from the given query condition.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                                                    <tr class="inherited" id="isEmpty()">
        <td><a href="yii-db-querytrait.html#isEmpty()-detail">isEmpty()</a></td>
        <td>Returns a value indicating whether the give value is "empty".</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                    <tr class="inherited" id="normalizeOrderBy()">
        <td><a href="yii-db-querytrait.html#normalizeOrderBy()-detail">normalizeOrderBy()</a></td>
        <td>Normalizes format of ORDER BY data</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                                                                        </table>
</div>

<a id="events"></a>

<a id="constants"></a>

<h2>Property Details</h2>

<div class="property-doc">

    <div class="detail-header h3" id="$aggregations-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$aggregations-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L145" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L145" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $aggregations        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>List of aggregations to add to this query.</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html">http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$aggregations-detail">$aggregations</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;[]</span></div>


    <div class="detail-header h3" id="$fields-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$fields-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L94" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L94" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $fields        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The fields being retrieved from the documents. For example, <code>['id', 'name']</code>.
If not set, this option will not be applied to the query and no fields will be returned.
In this case the <code>_source</code> field will be returned by default which can be configured using <a href="yii-elasticsearch-query.html#source()-detail">source()</a>.
Setting this to an empty array will result in no fields being retrieved, which means that only the primaryKey
of a record will be available in the result.</p>
<p>For each field you may also add an array representing a <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html">script field</a>. Example:</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span>-&gt;fields = [
    <span class="hljs-string">'id'</span>,
    <span class="hljs-string">'name'</span>,
    <span class="hljs-string">'value_times_two'</span> =&gt; [
        <span class="hljs-string">'script'</span> =&gt; <span class="hljs-string">"doc['my_field_name'].value * 2"</span>,
    ],
    <span class="hljs-string">'value_times_factor'</span> =&gt; [
        <span class="hljs-string">'script'</span> =&gt; <span class="hljs-string">"doc['my_field_name'].value * factor"</span>,
        <span class="hljs-string">'params'</span> =&gt; [
            <span class="hljs-string">'factor'</span> =&gt; <span class="hljs-number">2.0</span>
        ],
    ],
]
</code></pre>
<blockquote class="note"><p><strong>Note: </strong>Field values are <a href="http://www.elastic.co/guide/en/elasticsearch/reference/1.x/_return_values.html#_return_values">always returned as arrays</a> even if they only have one value.</p>
</blockquote>

        <p>See also:</p><ul><li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html#search-request-fields</a></li><li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html</a></li><li><a href="yii-elasticsearch-query.html#fields()-detail">fields()</a></li><li><a href="yii-elasticsearch-query.html#source()-detail">source()</a></li></ul>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$fields-detail">$fields</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$filter-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$filter-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L134" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L134" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $filter        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The filter part of this search query. This is an array or json string that follows the format of
the elasticsearch <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html">Query DSL</a>.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.string">string</a></span> <a href="yii-elasticsearch-query.html#$filter-detail">$filter</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$highlight-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$highlight-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L140" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L140" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $highlight        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The highlight part of this search query. This is an array that allows to highlight search results
on one or more fields.</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-highlighting.html">http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-highlighting.html</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$highlight-detail">$highlight</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$index-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$index-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L111" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L111" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $index        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The index to retrieve data from. This can be a string representing a single index
or a an array of multiple indexes. If this is not set, indexes are being queried.</p>

        <p>See also <a href="yii-elasticsearch-query.html#from()-detail">from()</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$index-detail">$index</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$minScore-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$minScore-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L161" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L161" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $minScore        <span class="detail-header-tag small">
            public                                                property
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p>Exclude documents which have a _score less than the minimum specified in min_score</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-min-score.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-min-score.html</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.float">float</a></span> <a href="yii-elasticsearch-query.html#$minScore-detail">$minScore</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$options-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$options-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L167" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L167" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $options        <span class="detail-header-tag small">
            public                                                property
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p>List of options that will passed to commands created by this query.</p>

        <p>See also <a href="yii-elasticsearch-command.html#$options-detail">yii\elasticsearch\Command::$options</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$options-detail">$options</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;[]</span></div>


    <div class="detail-header h3" id="$query-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$query-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L129" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L129" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $query        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The query part of this search query. This is an array or json string that follows the format of
the elasticsearch <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html">Query DSL</a>.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.string">string</a></span> <a href="yii-elasticsearch-query.html#$query-detail">$query</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$source-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$source-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L105" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L105" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $source        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>This option controls how the <code>_source</code> field is returned from the documents. For example, <code>['id', 'name']</code>
means that only the <code>id</code> and <code>name</code> field should be returned from <code>_source</code>.
If not set, it means retrieving the full <code>_source</code> field unless <a href="yii-elasticsearch-query.html#fields()-detail">fields()</a> are specified.
Setting this option to <code>false</code> will disable return of the <code>_source</code> field, this means that only the primaryKey
of a record will be available in the result.</p>

        <p>See also:</p><ul><li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html</a></li><li><a href="yii-elasticsearch-query.html#source()-detail">source()</a></li><li><a href="yii-elasticsearch-query.html#fields()-detail">fields()</a></li></ul>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$source-detail">$source</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$stats-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$stats-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L150" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L150" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $stats        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The 'stats' part of the query. An array of groups to maintain a statistics aggregation for.</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#stats-groups">http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#stats-groups</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$stats-detail">$stats</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;[]</span></div>


    <div class="detail-header h3" id="$suggest-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$suggest-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L155" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L155" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $suggest        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>List of suggesters to add to this query.</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$suggest-detail">$suggest</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;[]</span></div>


    <div class="detail-header h3" id="$timeout-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$timeout-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L124" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L124" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $timeout        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>A search timeout, bounding the search request to be executed within the specified time value
and bail with the hits accumulated up to that point when expired. Defaults to no timeout.</p>

        <p>See also:</p><ul><li><a href="yii-elasticsearch-query.html#timeout()-detail">timeout()</a></li><li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5</a></li></ul>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.integer">integer</a></span> <a href="yii-elasticsearch-query.html#$timeout-detail">$timeout</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$type-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#$type-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L117" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L117" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $type        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The type to retrieve data from. This can be a string representing a single type
or a an array of multiple types. If this is not set, all types are being queried.</p>

        <p>See also <a href="yii-elasticsearch-query.html#from()-detail">from()</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-elasticsearch-query.html#$type-detail">$type</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>

</div>
<h2>Method Details</h2>

<div class="method-doc">

    <div class="detail-header h3" id="addAgg()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#addAgg()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L439" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L439" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addAgg()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an aggregation to this query.</strong></p>

        <p>This is an alias for <a href="yii-elasticsearch-query.html#addAggregation()-detail">addAggregation()</a>.</p>

        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html">http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#addAgg()-detail">addAgg</a></strong> ( <span style="color: #0000BB">$name</span>, <span style="color: #0000BB">$type</span>, <span style="color: #0000BB">$options</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$name</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The name of the aggregation</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$type</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The aggregation type. e.g. <code>terms</code>, <code>range</code>, <code>histogram</code>...</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The configuration options for this aggregation. Can be an array or a json string.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="addAggregation()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#addAggregation()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L422" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L422" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addAggregation()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an aggregation to this query.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html">http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#addAggregation()-detail">addAggregation</a></strong> ( <span style="color: #0000BB">$name</span>, <span style="color: #0000BB">$type</span>, <span style="color: #0000BB">$options</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$name</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The name of the aggregation</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$type</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The aggregation type. e.g. <code>terms</code>, <code>range</code>, <code>histogram</code>...</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The configuration options for this aggregation. Can be an array or a json string.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="addOptions()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#addOptions()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L647" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L647" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addOptions()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds more options, overwriting existing options.</strong></p>

        
        <p>See also <a href="yii-elasticsearch-query.html#options()-detail">options()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#addOptions()-detail">addOptions</a></strong> ( <span style="color: #0000BB">$options</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The options to be added.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">throws</th>
                  <td class="param-type-col"><a href="yii-base-invalidparamexception.html">yii\base\InvalidParamException</a></td>
                  <td class="param-desc-col"><p>if $options is not an array</p>
</td>
                </tr>
                        </table>

<!--	-->

    <div class="detail-header h3" id="addSuggester()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#addSuggester()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L451" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L451" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addSuggester()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds a suggester to this query.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#addSuggester()-detail">addSuggester</a></strong> ( <span style="color: #0000BB">$name</span>, <span style="color: #0000BB">$definition</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$name</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The name of the suggester</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$definition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The configuration options for this suggester. Can be an array or a json string.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="all()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#all()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L206" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L206" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        all()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns all results as an array.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-elasticsearch-query.html#all()-detail">all</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The query results. If the query results in nothing, an empty array will be returned.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="batch()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#batch()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L497" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L497" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        batch()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Starts a batch query.</strong></p>

        <p>A batch query supports fetching data in batches, which can keep the memory usage under a limit.
This method will return a <a href="yii-elasticsearch-batchqueryresult.html">yii\elasticsearch\BatchQueryResult</a> object which implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
<p>For example,</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> Query)-&gt;from(<span class="hljs-string">'user'</span>);
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$query</span>-&gt;batch() <span class="hljs-keyword">as</span> <span class="hljs-variable">$rows</span>) {
    <span class="hljs-comment">// $rows is an array of 10 or fewer rows from user table</span>
}
</code></pre>
<p>Batch size is determined by the <code>limit</code> setting (note that in scan mode batch limit is per shard).</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-batchqueryresult.html">yii\elasticsearch\BatchQueryResult</a></span> <strong><a href="yii-elasticsearch-query.html#batch()-detail">batch</a></strong> ( <span style="color: #0000BB">$scrollWindow&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'1m'</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$scrollWindow</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>How long Elasticsearch should keep the search context alive,
in <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units">time units</a></p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection. If not set, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-batchqueryresult.html">yii\elasticsearch\BatchQueryResult</a></td>
                  <td class="param-desc-col"><p>The batch query result. It implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="column()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#column()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L338" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L338" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        column()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns the first column of the result.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-elasticsearch-query.html#column()-detail">column</a></strong> ( <span style="color: #0000BB">$field</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$field</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The field to query over</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The first column of the query result. An empty array is returned if the query results in nothing.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="count()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#count()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L366" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L366" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        count()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the number of records.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.integer">integer</a></span> <strong><a href="yii-elasticsearch-query.html#count()-detail">count</a></strong> ( <span style="color: #0000BB">$q&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'*'</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The COUNT expression. This parameter is ignored by this implementation.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.integer">integer</a></td>
                  <td class="param-desc-col"><p>Number of records</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="createCommand()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#createCommand()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L189" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L189" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        createCommand()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Creates a DB command that can be used to execute this query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-command.html">yii\elasticsearch\Command</a></span> <strong><a href="yii-elasticsearch-query.html#createCommand()-detail">createCommand</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-command.html">yii\elasticsearch\Command</a></td>
                  <td class="param-desc-col"><p>The created DB command instance.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="delete()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#delete()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L302" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L302" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        delete()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and deletes all matching documents.</strong></p>

        <p>Everything except query and filter will be ignored.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-elasticsearch-query.html#delete()-detail">delete</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span>, <span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The options given with this query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The query results.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="each()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#each()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L526" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L526" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        each()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Starts a batch query and retrieves data row by row.</strong></p>

        <p>This method is similar to <a href="yii-elasticsearch-query.html#batch()-detail">batch()</a> except that in each iteration of the result,
only one row of data is returned. For example,</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> Query)-&gt;from(<span class="hljs-string">'user'</span>);
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$query</span>-&gt;each() <span class="hljs-keyword">as</span> <span class="hljs-variable">$row</span>) {
}
</code></pre>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-batchqueryresult.html">yii\elasticsearch\BatchQueryResult</a></span> <strong><a href="yii-elasticsearch-query.html#each()-detail">each</a></strong> ( <span style="color: #0000BB">$scrollWindow&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'1m'</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$scrollWindow</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>How long Elasticsearch should keep the search context alive,
in <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units">time units</a></p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection. If not set, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-batchqueryresult.html">yii\elasticsearch\BatchQueryResult</a></td>
                  <td class="param-desc-col"><p>The batch query result. It implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="exists()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#exists()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L385" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L385" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        exists()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns a value indicating whether the query result contains any row of data.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.boolean">boolean</a></span> <strong><a href="yii-elasticsearch-query.html#exists()-detail">exists</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>Whether the query result contains any row of data.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="fields()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#fields()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L570" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L570" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        fields()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the fields to retrieve from the documents.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#fields()-detail">fields</a></strong> ( <span style="color: #0000BB">$fields</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$fields</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The fields to be selected.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="filter()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#filter()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L542" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L542" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        filter()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the filter part of this search query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#filter()-detail">filter</a></strong> ( <span style="color: #0000BB">$filter</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$filter</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"></td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="from()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#from()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L557" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L557" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        from()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the index and type to retrieve documents from.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-multi-index-type">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-multi-index-type</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#from()-detail">from</a></strong> ( <span style="color: #0000BB">$index</span>, <span style="color: #0000BB">$type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$index</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The index to retrieve data from. This can be a string representing a single index
or a an array of multiple indexes. If this is <code>null</code> it means that all indexes are being queried.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$type</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The type to retrieve data from. This can be a string representing a single type
or a an array of multiple types. If this is <code>null</code> it means that all types are being queried.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="highlight()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#highlight()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L408" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L408" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        highlight()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets a highlight parameters to retrieve from the documents.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#highlight()-detail">highlight</a></strong> ( <span style="color: #0000BB">$highlight</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$highlight</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>Array of parameters to highlight results.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="init()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#init()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L173" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L173" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        init()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Initializes the object.</strong></p>

        <p>This method is invoked at the end of the constructor after the object is initialized with the
given configuration.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">void</span> <strong><a href="yii-elasticsearch-query.html#init()-detail">init</a></strong> ( )</td></tr>
            </table>

<!--	-->

    <div class="detail-header h3" id="minScore()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#minScore()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L615" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L615" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        minScore()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong></strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-min-score.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-min-score.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">static</span> <strong><a href="yii-elasticsearch-query.html#minScore()-detail">minScore</a></strong> ( <span style="color: #0000BB">$minScore</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$minScore</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.float">float</a></td>
                  <td class="param-desc-col"><p>Exclude documents which have a <code>_score</code> less than the minimum specified minScore</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col">static</td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="one()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#one()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L250" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L250" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        one()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns a single row of result.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.boolean">boolean</a></span> <strong><a href="yii-elasticsearch-query.html#one()-detail">one</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>The first row (in terms of an array) of the query result. False is returned if the query
results in nothing.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="options()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#options()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L629" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L629" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        options()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the options to be passed to the command created by this query.</strong></p>

        
        <p>See also <a href="yii-elasticsearch-command.html#$options-detail">yii\elasticsearch\Command::$options</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#options()-detail">options</a></strong> ( <span style="color: #0000BB">$options</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The options to be set.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">throws</th>
                  <td class="param-type-col"><a href="yii-base-invalidparamexception.html">yii\base\InvalidParamException</a></td>
                  <td class="param-desc-col"><p>if $options is not an array</p>
</td>
                </tr>
                        </table>

<!--	-->

    <div class="detail-header h3" id="populate()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#populate()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L224" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L224" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        populate()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.4)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Converts the raw query results into the format as specified by this query.</strong></p>

        <p>This method is internally used to convert the data fetched from database
into the format as required by this query.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-elasticsearch-query.html#populate()-detail">populate</a></strong> ( <span style="color: #0000BB">$rows</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$rows</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The raw query result from database</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The converted query result</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="query()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#query()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L466" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L466" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        query()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the querypart of this search query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#query()-detail">query</a></strong> ( <span style="color: #0000BB">$query</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$query</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"></td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="scalar()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#scalar()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L316" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L316" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        scalar()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the query result as a scalar value.</strong></p>

        <p>The value returned will be the specified field in the first document of the query results.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a></span> <strong><a href="yii-elasticsearch-query.html#scalar()-detail">scalar</a></strong> ( <span style="color: #0000BB">$field</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$field</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>Name of the attribute to select</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The value of the specified attribute in the first record of the query result.
Null is returned if the query result is empty or the field does not exist.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="search()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#search()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L272" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L272" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        search()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns the complete search result including e.g. hits, facets, totalCount.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-elasticsearch-query.html#search()-detail">search</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span>, <span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-elasticsearch-connection.html">yii\elasticsearch\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to execute the query.
If this parameter is not given, the <code>elasticsearch</code> application component will be used.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$options</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The options given with this query. Possible options are:</p>
<ul>
<li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#search-routing">routing</a></li>
<li><a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html">search_type</a></li>
</ul>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The query results.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="source()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#source()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L586" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L586" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        source()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the source filtering, specifying how the <code>_source</code> field of the document should be returned.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#source()-detail">source</a></strong> ( <span style="color: #0000BB">$source</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$source</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The source patterns to be selected.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="stats()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#stats()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L396" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L396" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        stats()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds a 'stats' part to the query.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#stats-groups">http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html#stats-groups</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#stats()-detail">stats</a></strong> ( <span style="color: #0000BB">$groups</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$groups</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>An array of groups to maintain a statistics aggregation for.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="timeout()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-elasticsearch-query.html#timeout()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2-elasticsearch/edit/master/Query.php#L603" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2-elasticsearch/blob/master/Query.php#L603" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        timeout()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the search timeout.</strong></p>

        
        <p>See also <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5">http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-elasticsearch-query.html">$this</a></span> <strong><a href="yii-elasticsearch-query.html#timeout()-detail">timeout</a></strong> ( <span style="color: #0000BB">$timeout</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$timeout</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.integer">integer</a></td>
                  <td class="param-desc-col"><p>A search timeout, bounding the search request to be executed within the specified time value
and bail with the hits accumulated up to that point when expired. Defaults to no timeout.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-elasticsearch-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->
</div>
        </div>
</div>

<script type="text/javascript">
    /*<![CDATA[*/
    $("a.toggle").on('click', function () {
        var $this = $(this);
        if ($this.hasClass('properties-hidden')) {
            $this.text($this.text().replace(/Show/,'Hide'));
            $this.parents(".summary").find(".inherited").show();
            $this.removeClass('properties-hidden');
        } else {
            $this.text($this.text().replace(/Hide/,'Show'));
            $this.parents(".summary").find(".inherited").hide();
            $this.addClass('properties-hidden');
        }

        return false;
    });
    /*
     $(".sourceCode a.show").toggle(function () {
     $(this).text($(this).text().replace(/show/,'hide'));
     $(this).parents(".sourceCode").find("div.code").show();
     },function () {
     $(this).text($(this).text().replace(/hide/,'show'));
     $(this).parents(".sourceCode").find("div.code").hide();
     });
     $("a.sourceLink").click(function () {
     $(this).attr('target','_blank');
     });
     */
    /*]]>*/
</script>


</div>

<footer class="footer">
        <p class="pull-right"><small>Page generated on Sat, 09 Jul 2016 12:15:55 +0000</small></p>
    Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></footer>

<script type="text/javascript">jQuery(document).ready(function () {
    var shiftWindow = function () { scrollBy(0, -50) };
    if (location.hash) setTimeout(shiftWindow, 1);
    window.addEventListener("hashchange", shiftWindow);
var element = document.createElement("script");
element.src = "./jssearch.index.js";
document.body.appendChild(element);

var searchBox = $('#searchbox');

// search when typing in search field
searchBox.on("keyup", function(event) {
    var query = $(this).val();

    if (query == '' || event.which == 27) {
        $('#search-resultbox').hide();
        return;
    } else if (event.which == 13) {
        var selectedLink = $('#search-resultbox a.selected');
        if (selectedLink.length != 0) {
            document.location = selectedLink.attr('href');
            return;
        }
    } else if (event.which == 38 || event.which == 40) {
        $('#search-resultbox').show();

        var selected = $('#search-resultbox a.selected');
        if (selected.length == 0) {
            $('#search-results').find('a').first().addClass('selected');
        } else {
            var next;
            if (event.which == 40) {
                next = selected.parent().next().find('a').first();
            } else {
                next = selected.parent().prev().find('a').first();
            }
            if (next.length != 0) {
                var resultbox = $('#search-results');
                var position = next.position();

//              TODO scrolling is buggy and jumps around
//                resultbox.scrollTop(Math.floor(position.top));
//                console.log(position.top);

                selected.removeClass('selected');
                next.addClass('selected');
            }
        }

        return;
    }
    $('#search-resultbox').show();
    $('#search-results').html('<li><span class="no-results">No results</span></li>');

    var result = jssearch.search(query);

    if (result.length > 0) {
        var i = 0;
        var resHtml = '';

        for (var key in result) {
            if (i++ > 20) {
                break;
            }
            resHtml = resHtml +
            '<li><a href="' + result[key].file.u.substr(3) +'"><span class="title">' + result[key].file.t + '</span>' +
            '<span class="description">' + result[key].file.d + '</span></a></li>';
        }
        $('#search-results').html(resHtml);
    }
});

// hide the search results on ESC
$(document).on("keyup", function(event) { if (event.which == 27) { $('#search-resultbox').hide(); } });
// hide search results on click to document
$(document).bind('click', function (e) { $('#search-resultbox').hide(); });
// except the following:
searchBox.bind('click', function(e) { e.stopPropagation(); });
$('#search-resultbox').bind('click', function(e) { e.stopPropagation(); });

});</script></body>
</html>
